import React from 'react'
import { BrowserRouter, Switch, Route, Redirect } from 'react-router-dom'
import PublicRoute from '../../components/PublicRoute'
import PrivateRoute from '../../components/PrivateRoute'
import Login from '../Login'
import Register from '../Register'
import ForgotPassword from '../ForgotPassword'
import ResetPassword from '../ResetPassword'
import NotFound from '../NotFound'
import Dashboard from '../Dashboard'
import Demo from '../Demo'
import TransactionList from '../TransactionList'
import TransactionForm from '../TransactionForm'
import WalletList from '../WalletList'
import WalletForm from '../WalletForm'
import './index.less'

export default class App extends React.Component {
  render() {
    return (
      <BrowserRouter>
        <Switch>
          <Route exact path='/demo' component={() => <Demo />} />
          <PublicRoute exact path='/login' component={Login} />
          <PublicRoute exact path='/register' component={Register} />
          <PublicRoute exact path='/forgot_password' component={ForgotPassword} />
          <PublicRoute exact path='/reset_password' component={ResetPassword} />
          <PrivateRoute exact path='/' component={() => <Redirect to='/dashboard' />} />
          <PrivateRoute exact path='/home' component={() => <Redirect to='/dashboard' />} />
          <PrivateRoute exact path='/dashboard' component={Dashboard} />
          <PrivateRoute exact path='/transaction' component={TransactionList} />
          <PrivateRoute exact path='/transaction/create' component={props => <TransactionForm {...props} type='create' />} />
          <PrivateRoute exact path='/transaction/edit/:itemId' component={props => <TransactionForm {...props} type='edit' />} />
          <PrivateRoute exact path='/wallet' component={WalletList} />
          <PrivateRoute exact path='/wallet/create' component={props => <WalletForm {...props} type='create' />} />
          <PrivateRoute exact path='/wallet/edit/:itemId' component={props => <WalletForm {...props} type='edit' />} />
          <Route component={NotFound} />
        </Switch>
      </BrowserRouter>
    )
  }
}
